// 定义接口
export interface SpaceLevel {
  level: number
  name: string
}

// 定义常量
export const COMMON: SpaceLevel = { level: 0, name: '普通版' }
export const PRO: SpaceLevel = { level: 1, name: '专业版' }
export const FLAGSHIP: SpaceLevel = { level: 2, name: '旗舰版' }

export const SpaceLevelArray: SpaceLevel[] = [COMMON, PRO, FLAGSHIP]

export function getSpaceLevelByLevel(level: number): SpaceLevel | undefined {
  return SpaceLevelArray.find((status) => status.level === level)
}

export const SPACE_LEVEL_OPTIONS = [COMMON, PRO, FLAGSHIP].map((key) => {
  return {
    label: key.name,
    value: key.level,
  }
})

// 空间类型枚举
export const SPACE_TYPE_ENUM = {
  PRIVATE: 0,
  TEAM: 1,
}

// 空间类型文本映射
export const SPACE_TYPE_MAP: Record<number, string> = {
  0: '私有空间',
  1: '团队空间',
}

// 空间类型选项映射
export const SPACE_TYPE_OPTIONS = Object.keys(SPACE_TYPE_MAP).map((key) => {
  const value = Number(key) // 将字符串 key 转换为数字
  return {
    label: SPACE_TYPE_MAP[value],
    value,
  }
})

// 空间角色枚举
export const SPACE_ROLE_ENUM = {
  VIEWER: 'VIEWER',
  EDITOR: 'EDITOR',
  ADMIN: 'ADMIN',
} as const

// 空间角色文本映射
export const SPACE_ROLE_MAP: Record<string, string> = {
  VIEWER: '浏览者',
  EDITOR: '编辑者',
  ADMIN: '管理员',
}

// 空间角色选项映射
export const SPACE_ROLE_OPTIONS = Object.keys(SPACE_ROLE_MAP).map((key) => {
  return {
    label: SPACE_ROLE_MAP[key],
    value: key,
  }
})

/**
 * 空间权限常量
 */
export const SPACE_PERMISSION_ENUM = {
  SPACE_USER_MANAGE: 'spaceUser:manage',
  PICTURE_VIEW: 'picture:view',
  PICTURE_UPLOAD: 'picture:upload',
  PICTURE_EDIT: 'picture:edit',
  PICTURE_DELETE: 'picture:delete',
} as const
